import React, { Component } from 'react';
import { Link, Route, Redirect } from 'react-router-dom'
import Mylink from '@/components/Mylink';
import { HomeStyle , PageHome } from './style';
import First from './First/First';
import Shop from './Shop/Shop';
import Train from './Train/Train'
import Center from './Center/Center';
import connect from './connect';
@connect
class Home extends Component {
    componentDidMount() {
        this.props.getHome()
    }
    render() {
        console.log(this.props.home);
        let prefix = this.props.match.path
        return (
            <div>

                <HomeStyle className="top">
                    <Mylink to={`${prefix}/first`} tag="li">首页</Mylink>
                    <Mylink to={`${prefix}/shop`} tag="li">商家入驻</Mylink>
                    <Mylink to={`${prefix}/train`} tag="li">多多火车票</Mylink>
                    <Mylink to={`${prefix}/center`} tag="li">个人中心</Mylink>
                    <Redirect to={`${prefix}/first`}></Redirect>
                </HomeStyle>
                <PageHome>
                    <Route path={`${prefix}/first`} component={First} />
                    <Route path={`${prefix}/shop`} component={Shop} />
                    <Route path={`${prefix}/train`} component={Train} />
                    <Route path={`${prefix}/center`} component={Center} />
                </PageHome>

                
            </div>
        );
    }
}

export default Home;
